<?php 


include("./Public/Common.php");


//获取主照片
function getMainpic($uid){
    $result ;
    $result = D("Userpic")->getField("picUrl2","userID=$uid and isMain=1");
    //dump(D("Userpic")->getLastSql());
    if(!$result){
        $result = D("Userpic")->getField("picUrl2","userID=$uid");
    }
    if(!$result){
        $result = "./Public/file/nopic.jpg";
    }
    return $result;
}


function getPid($uid){
    $result ;
    $result = D("Userpic")->getField("id","userID=$uid and isMain=1");
    //dump(D("Userpic")->getLastSql());
    if(!$result){
        $result = D("Userpic")->getField("id","userID=$uid");
    }
    return $result;
}

//访问统计，增加
function staticInsert(){
    $stat = Cookie::get('stat');
    //dump($stat);
    if(!isset($stat)){
        $ip = $_SERVER['REMOTE_ADDR'];

        $Dao = D('Sysstat');
        $has = $Dao->count("ip=$ip");
        if($has>0) return;
        import('ORG.Net.IpLocation');
        $local = new IpLocation('./Public/Ipdata/wry.dat');
        $zone = $local->getlocation();
        $Dao->zone = $zone['area'].$zone['country'];
        //dump($Dao->zone);
        $Dao->ip = $ip;
        $Dao->cTime = time();
        $Dao->inUrl = $_SERVER['HTTP_REFERER'];
        $Dao->add();
        Cookie::set('stat','1',36000000);
    }
}

function statics(){
    $result =  D('Sysstat')->count();
    return $result;
}

?>